import HwTestReport
import time
import unittest
from quote.base.userbrowser import UseBrowser
from quote.util.operationxel import OperationExl
from quote.webpage.chaxunmanager.chaxunmanager import Chaxunmanager
from quote.webpage.usermanager.loginpage import LoginPage



class ChaxunSuc(unittest.TestCase):
    def setUp(self) -> None:
        self.oe = OperationExl()
        self.login = LoginPage()
        self.login.login("admin","admin")
        self.ch = Chaxunmanager()


    def test_1_chaxun(self):
        self.ch.chaxun(self.oe.get_cell_value(1,2))
        text=self.ch.huoqu()
        self.assertEqual(text,self.oe.get_cell_value(1,2))

    def tearDown(self) -> None:
        UseBrowser.quit()



if __name__ == '__main__':
    su = unittest.TestSuite()
    case_2 = unittest.TestLoader().loadTestsFromTestCase(ChaxunSuc)
    case = [case_2]
    su.addTests(case)
    now = time.strftime("%y_%m_%d_%H_%M", time.localtime())
    with open('../../../my_report{}.html'.format(now), 'wb+') as fp:
        runner = HwTestReport.HTMLTestReport(stream=fp,
                                             title='My auto test',
                                             description='This demonstrates the report output by HTMLTestRunner.',
                                             verbosity=3)
        runner.run(su)
